package engine

import (
	"bytes"
	"html/template"
)

type Engine interface {
	Render(tplName string, data interface{}) ([]byte, error)
}

type GoEngine struct {
	Tpl *template.Template
}

func (g *GoEngine) Render(tplName string, data interface{}) ([]byte, error) {
	val := &bytes.Buffer{}
	err := g.Tpl.ExecuteTemplate(val, tplName, data)
	if err != nil {
		return nil, err
	}
	return val.Bytes(), nil
}

var _ Engine = &GoEngine{}
